# Install Git using Chocolatey
Write-Host "Installing Git using Chocolatey..." -ForegroundColor Green

# Check if Chocolatey is installed
if (Get-Command choco -ErrorAction SilentlyContinue) {
    Write-Host "Chocolatey found, installing Git..." -ForegroundColor Yellow
    choco install git -y
    
    Write-Host "Git installation completed!" -ForegroundColor Green
    Write-Host "Please restart PowerShell to use Git commands." -ForegroundColor Yellow
} else {
    Write-Host "Chocolatey not found. Installing Chocolatey first..." -ForegroundColor Yellow
    
    # Install Chocolatey
    Set-ExecutionPolicy Bypass -Scope Process -Force
    [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
    iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
    
    # Refresh environment
    $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
    
    # Install Git
    choco install git -y
    
    Write-Host "Chocolatey and Git installation completed!" -ForegroundColor Green
    Write-Host "Please restart PowerShell to use Git commands." -ForegroundColor Yellow
}